<extend name="Public/base"/>
<!-- 子导航 -->
<block name="sidebar">
    <include file="sidemenu" />
</block>
<block name="content">
<h3 class="col-md-7">文档列表(<{$_total}>)</h3>
<div class="col-md-5">
	<div class="input-group m-b search-form">
    	<div class="input-group-btn">
        	<span class="btn btn-default dropdown-toggle" id="sch-sort-txt" data-toggle="dropdown" data="<{$status}>"><if condition="get_status_title($status) eq ''">所有<else/>{:get_status_title($status)}</if>
            	<i class="fa fa-chevron-down"></i>
        	</span>
        	<ul class="dropdown-menu" id="sub-sch-menu">
            	<li><a href="javascript:void(0);" value="">所有</a></li>
            	<li><a href="javascript:void(0);" value="1">正常</a></li>
            	<li><a href="javascript:void(0);" value="0">禁用</a></li>
            	<li><a href="javascript:void(0);" value="2">待审核</a></li>
        	</ul>
        </div>
    	<input type="text" class="form-control" name="title" class="search-input" value="<{:I('title')}>">
   		<span class="input-group-btn">
       		<button class="btn btn-default" id="search" url="<{:U('article/mydocument','pid='.I('pid',0).'&cate_id='.$cate_id,false)}>" type="button"><span class="fa-search fa"></span></button>
    	</span>
    	<span class="input-group-btn search-dropdown" >
    		<button class="btn btn-default " type="button">高级<i class="fa fa-chevron-down"></i></button>
        </span>
        <div class="search-dropdown-con" style="display:none">
			<div class="row">
				<label>创建时间：</label>
                <input type="text" id="time-start" name="time-start" class="input-2x" value="" placeholder="起始时间" /> -
            	<div class="input-append date" id="datetimepicker"  style="display:inline-block">
            		<input type="text" id="time-end" name="time-end" class="input-2x" value="" placeholder="结束时间" />
            		<span class="add-on"><i class="icon-th"></i></span>
            	</div>
        	</div>
        	<div class="row" style="display:inline-block; margin-top:10px;" >
        		<label>创 建 者：</label>
                <input type="text" name="nickname" class="text input-2x" value="" placeholder="请输入用户名">
        	</div>
    	</div>
	</div>
</div>
<div class="row">
    <div class="col-lg-12">
    	<div class="panel panel-default">
       		<div class="panel-heading ">
				[
				<notempty name="rightNav">
				<volist name="rightNav" id="nav">
				<a href="<{:U('article/index','cate_id='.$nav['id'])}>"><{$nav.title}></a>
					<if condition="count($rightNav) gt $i"><i class="fa fa-angle-double-right"></i></if>
				</volist>
				<present name="article">：<a href="<{:U('article/index','cate_id='.$cate_id.'&pid='.$article['id'])}>"><{$article.title}></a></present>
				<else/>
				<empty name="position">全部<else/><a href="<{:U('article/index')}>">全部</a></empty>
					<foreach name="Think.config.DOCUMENT_POSITION" item="vo">
					<neq name="position" value="$key"><a href="<{:U('article/index',array('position'=>$key))}>"><{$vo}></a><else/><{$vo}></neq>&nbsp;
					</foreach>
				</notempty>
				]
				<eq name="allow" value="0">（该分类不允许发布内容）</eq>
				<if condition="count($model) gt 1">[ 模型：<empty name="model_id"><strong>全部</strong><else/><a href="<{:U('article/index',array('pid'=>$pid,'cate_id'=>$cate_id))}>">全部</a></empty>
					<volist name="model" id="vo">
					<neq name="model_id" value="$vo"><a href="<{:U('article/index',array('pid'=>$pid,'cate_id'=>$cate_id,'model_id'=>$vo))}>"><{$vo|get_document_model='title'}></a><else/><strong><{$vo|get_document_model='title'}></strong></neq>&nbsp;
					</volist>
				]</if>     			
       			<div class="btn-group pull-right">
               		<div class="btn-group">
        				<gt name="allow" value="0">
        					<button class="btn btn-labeled btn-success document_add dropdown-toggle" data-toggle="dropdown"  <if condition="count($model) eq 1">url="<{:U('article/add',array('cate_id'=>$cate_id,'pid'=>I('pid',0),'model_id'=>$model[0]))}>"</if>>新 增
        						<if condition="count($model) gt 1"><i class="fa fa-angle-down"></i></if>
        					</button>
        					<if condition="count($model) gt 1">
        					<ul class="dropdown-menu" role="menu">
        						<volist name="model" id="vo">
        						<li><a href="<{:U('article/add',array('cate_id'=>$cate_id,'model_id'=>$vo,'pid'=>I('pid',0)))}>"><{$vo|get_document_model='title'}></a></li>
        						</volist>
        					</ul>
        					</if>
        				<else/>
        					<button class="btn btn-labeled btn-success disabled" >新 增
        						<if condition="count($model) gt 1"><i class="btn-arrowdown"></i></if>
        					</button>
        				</gt>
        			</div>
                    <button class="btn btn-labeled btn-success ajax-post" target-form="ids" url="<{:U("Article/setStatus",array("status"=>1))}>">启 用</button>
        			<button class="btn btn-labeled btn-danger ajax-post" target-form="ids" url="<{:U("Article/setStatus",array("status"=>0))}>">禁 用</button>
        			<button class="btn btn-labeled btn-success ajax-post" target-form="ids" url="<{:U("Article/move")}>">移 动</button>
        			<button class="btn btn-labeled btn-success ajax-post" target-form="ids" url="<{:U("Article/copy")}>">复 制</button>
        			<button class="btn btn-labeled btn-success ajax-post" target-form="ids" hide-data="true" url="<{:U("Article/paste")}>">粘 贴</button>
        			<input type="hidden" class="hide-data" name="cate_id" value="<{$cate_id}>"/>
        			<input type="hidden" class="hide-data" name="pid" value="<{$pid}>"/>
        			<button class="btn btn-labeled btn-danger ajax-post confirm" target-form="ids" url="<{:U("Article/setStatus",array("status"=>-1))}>">删 除</button>
        			<!-- <button class="btn document_add" url="<{:U('article/batchOperate',array('cate_id'=>$cate_id,'pid'=>I('pid',0)))}>">导入</button> -->
        			<button class="btn btn-labeled btn-success list_sort" url="<{:U('sort',array('cate_id'=>$cate_id,'pid'=>I('pid',0)),'')}>">排序</button>
	         	</div>      			
       		</div>
    		<div class="table-responsive">
                <table class="table table-striped table-bordered table-hover">
                    <!-- 表头 -->
                    <thead>
                        <tr>  
                        	<th style="width: 5%" class="check-all">
                          		<div data-toggle="tooltip" data-title="全选" class="checkbox c-checkbox">
                             		<label>
                                		<input type="checkbox">
                                		<span class="fa fa-check"></span>
                             		</label>
                          		</div>
                       		</th>  
                            <volist name="list_grids" id="field">
                                <th><{$field.title}></th>
                            </volist>
                        </tr>
                    </thead>
        
                    <!-- 列表 -->
                    <tbody>
                        <volist name="list" id="data">
                            <tr>
                            	<td>
                          			<div class="checkbox c-checkbox">
                             			<label>
                                		<input type="checkbox" class="ids" value="<{$data['id']}>" name="ids[]">
                                		<span class="fa fa-check"></span>
                             			</label>
                          			</div>
                       			</td>
                                <volist name="list_grids" id="grid">
                                    <td><{:get_list_field($data,$grid,$model_list)}></td>
                                </volist>
                            </tr>
                        </volist>
                    </tbody>
                </table>
    		</div>
    		<!-- 结束 表格 -->
    		<div class="panel-footer">
    			<div class="row">
					<ul class="pagination">
					<{$_page}>
					</ul>
				 </div>
            </div>    		
    	</div>
	</div>
</div>
</block>

</block>
<block name="script">
<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
<php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript">
$('#head-menu').find('a[href="<{:U('Article/index')}>"]').closest('li').addClass('current');
$(function(){
	//搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
		var status = $("#sch-sort-txt").attr("data");
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
		if(status != ''){
			query += 'status=' + status + "&" + query;
        }
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
		window.location.href = url;
	});

	/* 状态搜索子菜单 */
	$("#sub-sch-menu li").find("a").each(function(){
		$(this).click(function(){
			var text = $(this).text();
			$("#sch-sort-txt").text(text).attr("data",$(this).attr("value"));
			$("#sub-sch-menu").addClass("hidden");
		})
	});

	//只有一个模型时，点击新增
	$('.document_add').click(function(){
		var url = $(this).attr('url');
		if(url != undefined && url != ''){
			window.location.href = url;
		}
	});

	//点击排序
	$('.list_sort').click(function(){
		var url = $(this).attr('url');
		var ids = $('.ids:checked');
		var param = '';
		if(ids.length > 0){
			var str = new Array();
			ids.each(function(){
				str.push($(this).val());
			});
			param = str.join(',');
		}

		if(url != undefined && url != ''){
			window.location.href = url + '/ids/' + param;
		}
	});

    //回车自动提交
    $('.search-form').find('input').keyup(function(event){
        if(event.keyCode===13){
            $("#search").click();
        }
    });

    $('#time-start').datetimepicker({
        format: 'yyyy-mm-dd',
        language:"zh-CN",
	    minView:2,
	    autoclose:true
    });

    $('#time-end').datetimepicker({
        format: 'yyyy-mm-dd',
        language:"zh-CN",
	    minView:2,
	    autoclose:true
    });
})
</script>
</block>
